import * as echarts from "echarts";

export const getDiseaseSubsidyOptions = (data: any) => {
  return {
    title: {
      top: 15,
      left: 10,
      textStyle: {
        fontSize: 16,
        color: "#fff",
      },
      text: "历年大病互助补助人数和补助金额统计",
    },
    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "shadow",
      },
    },
    legend: {
      right: 10,
      top: 15,
      label: {
        fontSize: 13,
        color: "#2F89CF",
      },
      data: [
        {
          name: "人数",
          itemStyle: { color: "rgb(135, 208, 104,1)" },
          textStyle: { color: "rgb(135, 208, 104,1)" },
        },
        {
          name: "金额(万元)",
          itemStyle: { color: "rgba(95, 187, 235, 1)" },
          textStyle: { color: "rgb(135, 208, 104,1)" },
        },
      ],
    },
    grid: {
      top: "25%",
      left: "3%",
      right: "4%",
      bottom: "3%",
      containLabel: true,
    },
    xAxis: [
      {
        type: "category",
        data: data.year,
      },
    ],
    yAxis: [
      {
        type: "value",
        name: "人数",
        axisLabel: {
          padding: [3, 0, 0, 0],
          formatter: "{value}",
          color: "rgb(135, 208, 104,1)",
          fontSize: 11,
        },

        splitLine: {
          show: true,
          lineStyle: {
            color: "rgb(135, 208, 104,0)",
          },
        },
      },
      {
        type: "value",
        name: "金额(万元)",
        axisLabel: {
          padding: [3, 0, 0, 0],
          formatter: "{value}(万元)",
          color: "rgba(95, 187, 235, 1)",
          fontSize: 11,
        },
        splitLine: {
          show: true,
          lineStyle: {
            color: "rgb(135, 208, 104,0)",
          },
        },
      },
    ],
    series: [
      {
        name: "人数",
        type: "bar",
        data: data.numbers,
        tooltip: {
          valueFormatter: function (value: string | number) {
            return value + " 人";
          },
        },
        label: {
          show: true,
          lineHeight: 10,
          formatter: "{c}",
          position: "top",
          color: "rgb(135, 208, 104,1)",
          fontSize: 10,
        },
        itemStyle: {
          color: new echarts.graphic.LinearGradient(
            0,
            0,
            0,
            1,
            [
              {
                offset: 0,
                color: "rgb(135, 208, 104,1)", // 0% 处的颜色
              },
              {
                offset: 0.98,
                color: "rgba(5, 213, 255, 0)", // 100% 处的颜色
              },
            ],
            false
          ),
          shadowColor: "rgb(135, 208, 104,1)",
          shadowBlur: 4,
        },
      },
      {
        name: "金额(万元)",
        type: "bar",
        data: data.amount,
        yAxisIndex: 1,
        label: {
          show: true,
          lineHeight: 10,
          formatter: "{c}",
          position: "top",
          color: "rgba(5, 213, 255, 1)",
          fontSize: 10,
        },
        itemStyle: {
          color: new echarts.graphic.LinearGradient(
            0,
            0,
            0,
            1,
            [
              {
                offset: 0,
                color: "rgba(5, 213, 255, 1)", // 0% 处的颜色
              },
              {
                offset: 0.98,
                color: "rgba(5, 213, 255, 0)", // 100% 处的颜色
              },
            ],
            false
          ),
          shadowColor: "rgba(5, 213, 255, 1)",
          shadowBlur: 4,
        },
        tooltip: {
          valueFormatter: function (value: string | number) {
            return value + " 万元";
          },
        },
      },
    ],
  };
};
